<?php
class Db_Template extends MVC_SQL {
	public function __construct(){
		$this->setTable('ams_template');
	}
	
	public function doUpdateTemplate($aData){
		//var_dump($aData);die();
		if($aData['id']=='')
		{
			unset($aData['id']);
		}
		return $this->doUpdateByPK($aData);
	}
	public function getInfoTemplate($iId){
		return $this->getRecordsetByPK($iId);
	}
	public function check_exit_template_id($id)
	{
		$sSql = "SELECT * FROM ams_template WHERE id={$id}";
		return $this->getRecordsetExtend($sSql);
	}
	
	public function getListTemplate($oModel){
		$oModel->oNavigator = new paging();
		$page_size = $oModel->getData('page_size');
		$pagegroup_size = $oModel->getData('pagegroup_size');
		$stylesheet = $oModel->getData('stylesheet');
		
		$sSql = "SELECT * FROM ams_template WHERE 1 ORDER BY id";
		
		$total_record = $this->getNumRow($sSql);
		$oModel->oNavigator->init($sSql, $total_record, $page_size, $pagegroup_size, 'pUser', $stylesheet);
		$sSql = $oModel->oNavigator->getSql();
		
		return $this->getRecordsetExtend($sSql);
	}
	
	public function getAllRecord(){
		$sSql = "SELECT * FROM ams_template" ;
		return $this->getRecordsetExtend($sSql);
	}
	
	
}
